//
//  CollectCell.m
//  Project
//
//  Created by 冯东辉 on 2018/9/20.
//  Copyright © 2018年 FengDongHui. All rights reserved.
//

#import "CollectCell.h"

@implementation CollectCell

- (void)awakeFromNib {
    
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    
    [super setSelected:selected animated:animated];
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
    
        [self creatSubViews];
    }
    
    return self;
}

- (void)creatSubViews {
    
    _baseV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, GET_SCREEN_WIDTH()-20, 40)];
    _baseV.backgroundColor = UICOLOR_HEX(0xffffffff);
    [self.contentView addSubview:_baseV];
    
    _leftL = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, _baseV.width-10, _baseV.height)];
    _leftL.textColor = UICOLOR_HEX(0xff666666);
    _leftL.textAlignment = NSTextAlignmentLeft;
    _leftL.font = [UIFont systemFontOfSize:15];
    [_baseV addSubview:_leftL];
    
    _rightL = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, _baseV.width-10, _baseV.height)];
    _rightL.textColor = UICOLOR_HEX(0xff999999);
    _rightL.textAlignment = NSTextAlignmentRight;
    _rightL.font = [UIFont boldSystemFontOfSize:15];
    [_baseV addSubview:_rightL];
}

- (void)reloadSubViewsWithData:(NSMutableArray *)data indexPath:(NSIndexPath *)index {
    
    NSDictionary *dic = data[index.section];
    NSArray *array = dic[@"list"];
    NSDictionary *dic_data = array[index.row];
    
    _leftL.text = [NSString stringWithFormat:@"%@", dic_data[@"inD_Name"]];
    NSString *inD_DATA = [NSString stringWithFormat:@"%@", dic_data[@"inD_DATA"]];
    if ([ProjectTools isValiString:inD_DATA]) {
        inD_DATA = @"0.00";
    }
    _rightL.text = [NSString stringWithFormat:@"%.2f", [inD_DATA floatValue]];
    
    CGRect rect = [ProjectTools getStringRectWithString:_rightL.text font:_rightL.font maxSize:CGSizeMake(GET_SCREEN_WIDTH(), _rightL.height)];
    _rightL.frame = CGRectMake(_baseV.width-rect.size.width-10, 0, rect.size.width, _baseV.height);
    _leftL.frame = CGRectMake(10, 0, _rightL.left-10, _baseV.height);
    
    if (index.row+1 == [array count]) {
        
        [ProjectTools setBorderWithView:_baseV top:NO left:YES bottom:YES right:YES borderColor:UICOLOR_HEX(0xffEDEEEF) borderWidth:1.0f];
    }else {
        [ProjectTools setBorderWithView:_baseV top:NO left:YES bottom:NO right:YES borderColor:UICOLOR_HEX(0xffEDEEEF) borderWidth:1.0f];
    }
}

@end
